package com.codes.core.utils;

import java.text.NumberFormat;

/**
 * @Date 2020/6/1 18:25
 * @Created by peanut
 */
public class NubmerUtil {




    public static String baifenbi(int a, int b){
        // 防止除数为 0
        if(0 == b) b=1;
        // 创建一个数值格式化对象
        NumberFormat numberFormat = NumberFormat.getInstance();
        // 设置精确到小数点后2位
        numberFormat.setMaximumFractionDigits(2);
        String result = numberFormat.format((float)a/(float)b*100);
        return result+"%";
    }




}